<template>
  <h1>猜数字游戏</h1>
  <input type="text" placeholder="输入1-100以内的数字" v-model="num">
  <button @click="cyc()">猜一猜</button>
  <h2>{{ p }}</h2>
</template>
<script setup>
import {ref} from "vue";

const p = ref('')
const num = ref('');

const ranm = parseInt(Math.random() * 100) + 1;
console.log(ranm)
const cyc = () => {
  if (num.value > ranm) {
    p.value = '猜大了'
  } else if (num.value < ranm) {
    p.value = '猜小了'
  } else {
    p.value = '猜对了'
  }

}
</script>

<style scoped>

</style>